package com.eshop.eshop2021_v1.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: 若若叶
 * @date: 2021/10/11 9:14 FileName: InterceptorConfig Description:
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    List<String> list = new ArrayList<>();
    list.add("/");
    list.add("/user/register");
    list.add("/user/doLeg");
    list.add("/user/checkedEmail");
    list.add("/user/toLogin");
    list.add("/user/sendEmail");
    list.add("/user/doLogin");
    list.add("/user/register");
    list.add("/getCode");
    list.add("/css/**");
    list.add("/fonts/**");
    list.add("/images/**");
    list.add("/js/**");
    list.add("/test");
    InterceptorRegistration interceptorRegistration =
        registry.addInterceptor(new LoginInterceptor());
    interceptorRegistration.addPathPatterns("/**").excludePathPatterns(list);
  }
}
